﻿using System;
using iPdf.Properties;
using Elegant.Ui;


namespace iPdf
{
    class SmallCloseButton : Button
    {
        static SmallCloseButton()
        {
            AddSkin();
        }

        private static void AddSkin()
        {
            if (!SkinManager.ContainsProduct("Vista"))
                SkinManager.AddProduct("Vista");

            Glyph test;
            if (!SkinManager.TryGetGlyph("SmallCloseButton.Normal", out test)) // For VS designer to open more then once.
            {
                TextureGlyph glyph = (TextureGlyph)SkinManager.AddNewGlyph("Vista", typeof(TextureGlyph), "SmallCloseButton.Normal");
                glyph.Texture = Resources.SmallCloseButtonNormal;

                glyph = (TextureGlyph)SkinManager.AddNewGlyph("Vista", typeof(TextureGlyph), "SmallCloseButton.Hovered");
                glyph.Texture = Resources.SmallCloseButtonHovered;

                glyph = (TextureGlyph)SkinManager.AddNewGlyph("Vista", typeof(TextureGlyph), "SmallCloseButton.Pressed");
                glyph.Texture = Resources.SmallCloseButtonPressed;

                glyph = (TextureGlyph)SkinManager.AddNewGlyph("Vista", typeof(TextureGlyph), "SmallCloseButton.Disabled");
                glyph.Texture = Resources.SmallCloseButtonDisabled;

                SkinManager.AddNewSkin("Vista", typeof(ButtonSkin), "SmallCloseButton");
            }
        }

        public SmallCloseButton()
        {
            Size = Resources.SmallCloseButtonNormal.Size;
        }


        /// <summary>
        /// This item supports the framework infrastructure and is not intended to be used directly from your code.
        /// </summary>
        protected override void OnSkinChanged(EventArgs e)
        {
            base.OnSkinChanged(e);

            Skin.GetPaintInformation(ButtonState.Normal).BackgroundGlyphName = "SmallCloseButton.Normal";

            Skin.GetPaintInformation(ButtonState.Hovered).BackgroundGlyphName = "SmallCloseButton.Hovered";

            Skin.GetPaintInformation(ButtonState.Pressing).BackgroundGlyphName = "SmallCloseButton.Pressed";

            Skin.GetPaintInformation(ButtonState.Disabled).BackgroundGlyphName = "SmallCloseButton.Disabled";

            Skin.GetPaintInformation(ButtonState.Default).BackgroundGlyphName = "SmallCloseButton.Normal";
            Skin.GetPaintInformation(ButtonState.DefaultFocused).BackgroundGlyphName = "SmallCloseButton.Hovered";
            Skin.GetPaintInformation(ButtonState.DefaultHovered).BackgroundGlyphName = "SmallCloseButton.Hovered";
            Skin.GetPaintInformation(ButtonState.DefaultPressing).BackgroundGlyphName = "SmallCloseButton.Pressed";
            Skin.GetPaintInformation(ButtonState.Focused).BackgroundGlyphName = "SmallCloseButton.Hovered";
        }

        /// <summary>
        /// Overrides the member from the base class.
        /// </summary>
        public override string ContextId
        {
            get { return "SmallCloseButton"; }
        }
    }
}
